<?php
class Ordermanager_Model_Pagedecision implements Ordermanager_Model_Mainable{
    
    private $action_handler;
    private $core_controller_csrftoken;
    private $get_account_status;
    
    public function main(array $variables = null) {
        //var_dump($variables);
        //die();
        switch($variables['get']['page']){
            case 'edytuj-zamowienia':
                return $this->edit_order($variables);
                break;
            case 'aktualizuj-zamowienie':
                return $this->update_order($variables);
                break;
            default:
                return $this->default_action($variables);
                break;
        }
    }
    
    private function update_order(array $variables = null){
        $this->action_handler = new Ordermanager_Model_Updateorder;
        return $this->action_handler->main($variables);
    }
    
    private function edit_order(array $variables = null){
        $this->action_handler = new Ordermanager_Data_Getorderdata;
        $page = $this->page_data($variables);
        $page['content'] = $this->action_handler->main($variables);
        return $page;
    }
    
    private function default_action(array $variables = null){
        unset($variables);
        $this->action_handler = new Ordermanager_Model_Ordermanager;
        return $this->action_handler->main($variables);
    }
    
    private function page_data(array $variables = null){
        $this->core_controller_csrftoken = new Core_Controller_Csrftoken;
        $this->get_account_status = new Accountsstatus_Data_Getaccountsstatus;
        $page['csrf_token'] = $this->core_controller_csrftoken->main($variables);
        $page['account_statuses'] = $this->get_account_status->main($variables);
        $page['template'] = WEB_ROOT_FOLDER."ordermanager/views/updateorder.php";
        return $page;
    }

}
